This is an example notebook for the prettyplotlib
plotting library. It is still under construction, so any feedback is welcome!
New syntax: Don't need to supply ax
everywhere!
For those of you using ppl.remove_chartjunk
, your code is now broken. Get it now via from prettyplotlib.utils import remove_chartjunk
In [1]:
import prettyplotlib as ppl
# Set the random seed for consistency
np.random.seed(12)
# Show the whole color range
for i in range(8):
x = np.random.normal(loc=i, size=1000)
y = np.random.normal(loc=i, size=1000)
ax = ppl.scatter(x, y, label=str(i))
ppl.legend(ax)
ax.set_title('prettyplotlib `scatter`')
Out[1]:
In [1]:
%load_ext autoreload
%autoreload 2
In [5]:
import prettyplotlib as ppl
# Set the random seed for consistency
np.random.seed(12)
# Show the whole color range
for i in range(8):
y = np.random.normal(size=1000).cumsum()
x = np.arange(1000)
# For now, you need to specify both x and y :(
# Still figuring out how to specify just one
ppl.plot(x, y, label=str(i), linewidth=0.75)
ppl.legend()
Out[5]:
In [2]:
import prettyplotlib as ppl
# Set the random seed for consistency
np.random.seed(12)
# Show the whole color range
for i in range(8):
y1 = np.random.normal(size=1000).cumsum()
y2 = np.random.normal(size=1000).cumsum()
x = np.arange(1000)
ppl.fill_between(x, y1, y2, label=str(i))
ppl.legend()
In [4]:
import prettyplotlib as ppl
# Set the random seed for consistency
np.random.seed(12)
# Show the whole color range
for i in range(8):
y1 = np.random.normal(size=1000).cumsum()
y2 = np.random.normal(size=1000).cumsum()
x = np.arange(1000)
ppl.fill_betweenx(x, y1, y2, label=str(i))
ppl.legend()
In [3]:
import prettyplotlib as ppl
from prettyplotlib import brewer2mpl
import numpy as np
import string
green_purple = brewer2mpl.get_map('PRGn', 'diverging', 11).mpl_colormap
np.random.seed(10)
fig = ppl.pcolormesh(np.random.randn(10,10),
xticklabels=string.uppercase[:10],
yticklabels=string.lowercase[-10:],
cmap=green_purple)
In [4]:
import prettyplotlib as ppl
from prettyplotlib import brewer2mpl
import numpy as np
import string
green_purple = brewer2mpl.get_map('PRGn', 'diverging', 11).mpl_colormap
np.random.seed(10)
fig = ppl.pcolormesh(np.random.randn(10,10),
xticklabels=string.uppercase[:10],
yticklabels=string.lowercase[-10:],
cmap=green_purple,
center_value=2)
In [12]:
import prettyplotlib as ppl
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(12)
# 'y' for the 'y' axis. Could also add a grid over the 'x' axis.
ppl.hist(np.random.randn(1000), grid='y')
Out[12]:
In [13]:
import prettyplotlib as ppl
import numpy as np
import string
np.random.seed(14)
n = 10
ppl.bar(np.arange(n), np.abs(np.random.randn(n)), annotate=True, grid='y')
Out[13]:
In [17]:
import prettyplotlib as ppl
import numpy as np
import string
np.random.seed(14)
n = 10
ppl.barh(np.arange(n), np.abs(np.random.randn(n)), annotate=True, grid='y')
Out[17]:
In [8]:
import prettyplotlib as ppl
import matplotlib as mpl
np.random.seed(10)
data = np.random.randn(8, 4)
labels = ['A', 'B', 'C', 'D']
ppl.boxplot(data, xticklabels=labels)
Out[8]:
In [ ]: